﻿using AiXiu.BLL;
using AiXiu.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AiXiu.WebSite
{
    public partial class Personal : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // 读取用户资料
                TBUsers user = IdentityManager.ReadUser();
                // 显示用户资料
                if (string.IsNullOrEmpty(user.Avatar))
                {
                    avatar.ImageUrl = "~/imgs/avatar.jpg";
                }
                else
                {
                    avatar.ImageUrl = user.Avatar;
                }
                lbName.Text = string.IsNullOrEmpty(user.NickName) ? "用户" + user.Id : user.NickName;
                lbAddress.Text = string.IsNullOrEmpty(user.Address) ? "未知地" : user.Address;
                lbHobby.Text = string.IsNullOrEmpty(user.Hobby) ? "未添加" : user.Hobby;
                lbBirthday.Text = user.Birthday.HasValue ? user.Birthday.Value.ToString("MM-dd") : "未设置";
            }
        }

        protected void SignOut_Click(object sender, EventArgs e)
        {
            System.Web.Security.FormsAuthentication.SignOut();
            Response.Redirect("Login.aspx");
        }
    }
}